package com.rz.htk.product.controller;

import com.rz.core.kit.RespKit;
import com.rz.core.resp.ResultResp;
import com.rz.htk.order.entity.Order;
import com.rz.htk.product.entity.ProductPrice;
import com.rz.htk.product.entity.vo.PrdDeleteParam;
import com.rz.htk.product.entity.vo.PrdPriceParam;
import com.rz.htk.product.service.IProductPriceService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @ClassName ProductPriceController
 * @Description 产品资费信息
 * @Author maweiyue
 * @Date 2019/3/27 15:28
 */
@RestController
@RequestMapping("price")
public class ProductPriceController {

    @Resource
    private IProductPriceService productPriceService;

    @PostMapping("/getPage")
    public ResultResp getPage(@RequestBody ProductPrice productPrice){
        return RespKit.success(this.productPriceService.getPage(productPrice));
    }

    @PostMapping("/savePrice")
    public ResultResp savePrice(@RequestBody ProductPrice productPrice){
        return RespKit.success(this.productPriceService.saveProductPrice(productPrice));
    }

    @PostMapping("/batchDelete")
    public ResultResp batchDelete(@RequestBody PrdDeleteParam prdDeleteParam){
        return RespKit.success(this.productPriceService.batchDelete(prdDeleteParam));
    }

    /**
     * 根据产品编号获取资费列表
     * @param prdCode 产品编号
     * @return
     */
    @PostMapping("/listByPrdCode/{prdCode}")
    public ResultResp batchDelete(@PathVariable String prdCode){
        return RespKit.success(this.productPriceService.listProductPriceByPrdcode(prdCode));
    }

    /**
     * 根据“国家”“产品”获取资费信息
     * @param price
     * @return
     */
    @PostMapping("/getDestination")
    public ResultResp getDestination(@RequestBody ProductPrice price){
        return RespKit.success(this.productPriceService.getDestination(price.getPrdCode(), price.getCountryCode()));
    }

    /**
     * 根据订单（产品、目的地、包裹重量）获取资费信息
     * @param order 订单信息
     * @return
     */
    @PostMapping("/listByOrder")
    public ResultResp listByOrder(@RequestBody Order order){
        return RespKit.success(this.productPriceService.getBestProductPrice(order));
    }

    /**
     * 报价（运费计算）
     * @param param
     * @return
     */
    @PostMapping("/quote")
    public ResultResp quote(@RequestBody PrdPriceParam param) {
        return RespKit.success(this.productPriceService.quote(param));
    }
}
